using System;
using System.Collections.Generic;
using System.Text;
using System.Web;

namespace KenLib.Common
{
    public sealed class SessionRepository
    {
        static SessionRepository _instance = null;
        static readonly object Padlock = new object();
        SessionRepository() { }
        public static SessionRepository Instance
        {
            get
            {
                if (_instance == null)
                {
                    lock (Padlock)
                    {
                        if (_instance == null)
                        {
                            _instance = new SessionRepository();
                        }
                    }
                }
                return _instance;
            }
        }
        public int LoginId
        {
            get
            {
                if (HttpContext.Current.Session["login"] != null)
                    return int.Parse(HttpContext.Current.Session["login"].ToString());
                else
                    return 0;
            }
            set
            {
                HttpContext.Current.Session["login"] = value;
            }
        }
        public int UserId
        {
            get
            {
                if (HttpContext.Current.Session["SessionManager"] != null)
                    return int.Parse(HttpContext.Current.Session["SessionManager"].ToString());
                else
                    return 0;
            }
            set
            {
                HttpContext.Current.Session["SessionManager"] = value;
            }
        }
        public string CMND
        {
            get
            {
                if (HttpContext.Current.Session["SessionLoginID"] != null)
                    return HttpContext.Current.Session["SessionLoginID"].ToString();
                else
                    return "";
            }
            set
            {
                HttpContext.Current.Session["SessionLoginID"] = value;
            }
        }
    }
}
